# https://blog.csdn.net/ztf312/article/details/84670721 来源
import matplotlib.pyplot as plt
import networkx as nx

n = 20  # 生成n个节点
k = 4  # 每个节点k个邻居
p = 0.3  # 以概率p随机化重连边
WS = nx.random_graphs.watts_strogatz_graph(n, k, p)
pos = nx.circular_layout(WS)  # 图形样式，这里是节点在一个圆环上均匀分布
nx.draw(WS, pos, with_labels=False, node_size=30)
plt.show()
